package cc.server.extension.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
//@Component
//public class MyInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        String url = request.getMethod() + " " + request.getRequestURI();
//        log.info("[PLUS]开始请求 => URL[{}]", url);
//        return true;
//    }
//}
@Component
public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String url = request.getMethod() + " " + request.getRequestURI();
        log.info("[PLUS]开始请求 => URL[{}]", url);
        // 在这里编写预处理逻辑
        return true;
    }

    // 其他的preHandle, postHandle, afterCompletion方法可以根据需要实现
}